#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
//priority_queue<int, vector<int>, greater<int>> pq;

signed main() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> ans;

    auto dfs = [&](auto&& dfs, vector<int> path, int u)->void {
        if(u == n){
            ans.push_back(path);
            return;
        }
        int t = path.back() + 10;
        for(int i = t; i <= k - (n - 1 - u) * 10; i++) {
            path.push_back(i);
            dfs(dfs, path, u + 1);
            path.pop_back();
        }
    };

    for(int i = 1; i <= k - (n - 1) * 10; i++) {
        dfs(dfs, {i}, 1);
    }
    cout << ans.size() << endl;
    for(auto arr : ans) {
        for(auto x : arr) {
            cout << x << ' ';
        }
        cout << endl;
    }
    return 0;
}